﻿// -------------------------------------------------------------------------
//    @FileName         :    NFAuctionCompetitionPart.cpp
//    @Author           :    gaoyi
//    @Date             :    24-8-30
//    @Email            :    445267987@qq.com
//    @Module           :    NFAuctionCompetitionPart
//
// -------------------------------------------------------------------------

#include "NFAuctionCompetitionPart.h"

#include "proto_cs_login.pb.h"
#include "proto_db.pb.h"

NFAuctionCompetitionPart::NFAuctionCompetitionPart()
{
    if (EN_OBJ_MODE_INIT == NFShmMgr::Instance()->GetCreateMode())
    {
        CreateInit();
    }
    else
    {
        ResumeInit();
    }
}

NFAuctionCompetitionPart::~NFAuctionCompetitionPart()
{
}

int NFAuctionCompetitionPart::CreateInit()
{
    return 0;
}

int NFAuctionCompetitionPart::ResumeInit()
{
    return 0;
}


int NFAuctionCompetitionPart::LoadFromDB(const proto_ff::tbRoleDetail* pDBData)
{
    m_stData.FromPb(pDBData->role_play_data().auction_competition_data());
    return 0;
}

int NFAuctionCompetitionPart::InitConfig(proto_ff::tbRoleDetail* pDbData, const RoleOne& stRoleOne)
{
    pDbData->mutable_role_play_data()->mutable_auction_competition_data()->set_credit_level(1);
    pDbData->mutable_role_play_data()->mutable_auction_competition_data()->set_credit_score(AUCTION_COMPETITION_INIT_CREDIT_CORE);
    pDbData->mutable_role_play_data()->mutable_auction_competition_data()->mutable_best_grade_info()->set_honor_grade(1);
    return 0;
}

int NFAuctionCompetitionPart::SaveDB(proto_ff::tbRoleDetail* pDBData)
{
    m_stData.ToPb(pDBData->mutable_role_play_data()->mutable_auction_competition_data());
    return 0;
}

int NFAuctionCompetitionPart::MakePlayerDataCS(proto_ff::Proto_CSGetRoleRsp* pCSGetRoleRsp)
{
    auto pRoleAuctionCompetitionData = pCSGetRoleRsp->mutable_auction_competition_data();
    if (m_stData.grade_info.size() > 0)
    {
        m_stData.grade_info[0].ToPb(pRoleAuctionCompetitionData->add_grade_info());
    }
    else
    {
        pRoleAuctionCompetitionData->add_grade_info();
    }
    pRoleAuctionCompetitionData->set_fight_count(m_stData.fight_count);
    pRoleAuctionCompetitionData->set_win_count(m_stData.win_count);
    pRoleAuctionCompetitionData->set_credit_score(m_stData.credit_score);
    pRoleAuctionCompetitionData->set_credit_level(m_stData.credit_level);
    pRoleAuctionCompetitionData->set_ban_end_time(m_stData.ban_end_time);
    pRoleAuctionCompetitionData->set_ban_info_clear_time(m_stData.ban_info_clear_time);
    pRoleAuctionCompetitionData->set_daily_win_count(m_stData.daily_win_count);
    pRoleAuctionCompetitionData->set_daily_reward(m_stData.daily_reward);
    pRoleAuctionCompetitionData->set_can_match_time(m_stData.can_match_time);
    m_stData.best_grade_info.ToPb(pRoleAuctionCompetitionData->mutable_best_grade_info());
    return 0;
}

int NFAuctionCompetitionPart::MakeCityPlayerData(proto_ff::CityRoleInfo* pGCCityRoleInfo)
{
    return 0;
}
